package ar.Location.Map;

import android.content.Context;
import android.graphics.Canvas;
import android.hardware.SensorListener;
import android.util.AttributeSet;
import android.widget.LinearLayout;

public class CompassView extends LinearLayout implements SensorListener {
	float mHeading = 0;

	public CompassView(Context context, AttributeSet attSet) {
		super(context, attSet);
	}

	@Override
	protected void dispatchDraw(Canvas canvas) {

		canvas.save(Canvas.MATRIX_SAVE_FLAG);
		canvas.rotate(-mHeading, getWidth() >> 1, getHeight() >> 1);
		super.dispatchDraw(canvas);
		canvas.restore();
	}

	public void onSensorChanged(int sensor, float[] values) {
		synchronized (this) {
			mHeading = values[0];
			invalidate();
		}
	}

	public void onAccuracyChanged(int sensor, int accuracy) {
		// TODO Auto-generated method stub

	}
}
